function limit()
{
	var targetId = "textbox";
	var countId = "say";
	
	var ammount = 1000;
	
	var warn1Start = 50;
	var warnColor1 = "gold";
	
	var warn2Start = 10;
	var warnColor2 = "red";
	
	var target = document.getElementById(targetId).value;
	var length = target.length;
	var allowed = ammount;
	var leftOver = allowed-length;
	
	if(leftOver == -1)
	{var count = document.getElementById(countId).innerHTML = "0";}
	else{var count = document.getElementById(countId).innerHTML = leftOver;}
	
	var startPoint = ammount-1;
	if(target.length > startPoint)
	{
		var keep = target.substring(0,ammount);
		document.getElementById(targetId).value = keep;
	}
	else
	{
		if(leftOver>warn1Start)
		{
		var counter = document.getElementById(countId);
		counter.style.color="#2b6ba1";
		counter.style.textDecoration="none";
		counter.style.fontSize="18px";
		}
		else if(leftOver>warn2Start)
		{
		var counter = document.getElementById(countId);
		counter.style.color=warnColor1;
		counter.style.textDecoration="none";
		counter.style.fontSize="18px";
		}
		else if (leftOver<warn2Start)
		{
		var counter = document.getElementById(countId);
		counter.style.color=warnColor2;
		counter.style.textDecoration="none";
		counter.style.fontSize="18px";		
		}

	}
}